package com.mergeades.chp04;

public class WaitTimeOut {

    public synchronized Object get(long mills) throws InterruptedException {
        long future = System.currentTimeMillis() + mills;
        long remaining = mills;
        Object result = null;
        while((result == null) && remaining > 0){
            wait(remaining);
            remaining = future - System.currentTimeMillis();
        }
        return result;
    }
}
